import type { PageResult,Contribute } from "@/types/mycontribute";
import type { ContributePageRequestDTO, ContributeSubmitDTO } from "@/types/mycontribute";
import { httpR2 } from "@/utils/http";

/**
 * 分页请求书本信息
 * @param query
 * @returns
 */
export const getContributeResultApi = (query: ContributePageRequestDTO) => {
  return httpR2<PageResult>({
    method: "POST",
    url: "/content/contribute/page",
    data: {
      ...query,
    },
  });
};

/**
 * 分页请求书本信息--公开信息获取
 * @param query
 * @returns
 */
export const getContributeResultListApi = (query: ContributePageRequestDTO) => {
  return httpR2<PageResult>({
    method: "POST",
    url: "/content/contribute/open/list",
    data: {
      ...query,
    },
  });
};

// /content/contribute/submit

export const submitContribute = (query: ContributeSubmitDTO) => {
  return httpR2<Contribute>({
    method: "POST",
    url: "/content/contribute/submit",
    data: {
      ...query,
    },
  });
};


export const updateContribute = (query: ContributeSubmitDTO) => {
  return httpR2<Contribute>({
    method: "POST",
    url: "/content/contribute",
    data: {
      ...query,
    },
  });
};


export const getContributeById = (query: number) => {
  return httpR2<Contribute>({
    method: "POST",
    url: `/content/contribute/${query}`,
    data: {
    },
  });
};


export const deleteContributeById = (query: number) => {
  return httpR2<Contribute>({
    method: "DELETE",
    url: `/content/contribute/quit/${query}`,
    data: {
    },
  });
};

